<template>
  <div class="publishCon">
    <Layout>
      <Row type="flex" justify="center" class="header">
        <Col span="21">
        <a class="klogo">
          <img src="./klogo.png" alt="">
        </a>
        <h1>전 세계 바이어들을 최고의 B2B 플랫폼</h1>
        <ul class="topNav">
          <!--<li>-->
          <!--<Dropdown trigger="click" style="margin-left: 20px">-->
          <!--<a href="javascript:void(0)" style="color: #fff">-->
          <!--languages-->
          <!--<Icon type="arrow-down-b"></Icon>-->
          <!--</a>-->
          <!--<DropdownMenu slot="list">-->
          <!--<DropdownItem>中文</DropdownItem>-->
          <!--<DropdownItem>한국어</DropdownItem>-->
          <!--</DropdownMenu>-->
          <!--</Dropdown>-->
          <!--</li>-->
          <li v-if="user||loginPhone">
            <span class="U">
              <Icon type="person"></Icon>
              <a class="userPhone" @click="myIndex">{{user || loginPhone}}</a>
              <span>|</span>
              <i class="iconfont icon-tuichu esc" @click="esc"></i>
            </span>
          </li>
          <li v-else>
            <span class="U">
              <a class="topLogin" @click="topLogin">로그인</a>
            </span>
          </li>
          <!--<li v-show="show.isHaveCityUserId">-->
          <li>
            <a @click="myStockUrl" class="myStock"><i class="iconfont icon-xingzhuang"></i>&nbsp;나의 시장조사</a>
          </li>
        </ul>
        </Col>
      </Row>
      <Content class="content">
        <Row type="flex" justify="center">
          <Col span="18">
          <Card>
            <p slot="title" v-html="INIT_DATA.main.purchase_title"></p>
            <a slot="extra" class="lotSize" v-html="INIT_DATA.main.purchase_button_batch" @click="Batch"></a>
            <!--<Button slot="extra" class="lotSize" v-html="INIT_DATA.main.purchase_button_batch" @click="Batch"></Button>-->

            <Row type="flex" justify="center">
              <Col span="18">
              <Form :model="formItem" :label-width="114" :rules="rulePublish">
                <FormItem :label="INIT_DATA.main.purchase_city_manage" v-show="!show.isHaveCityUserId" prop="manager">
                  <div class="selManBor" @click="showSelManage">
                    <Row type="flex" v-if="INIT_DATA.activeManger">
                      <Col span="24" class="mCard">
                      <Row type="flex" justify="space-between">
                        <Col span="13">
                        <div class="iblock">
                          <h3 class="showMName" v-html="INIT_DATA.activeManger.manageName"></h3>
                          <span class="showMPhone" v-html="INIT_DATA.activeManger.managePhone"></span>
                        </div>
                        </Col>
                        <Col span="8">
                        <div class="iblock">
                          <Avatar :src="INIT_DATA.activeManger.manageHeadImg" style="width: 60px;height: 60px"/>
                        </div>
                        </Col>
                      </Row>
                      </Col>
                    </Row>
                    <a v-else>{{INIT_DATA.main.purchase_click_select}}>>></a>
                  </div>
                </FormItem>
                <!--名称-->
                <FormItem :label="INIT_DATA.main.purchase_prod" prop="name">
                  <Input v-model="formItem.name" :placeholder="INIT_DATA.main.tips_prod" clearable></Input>
                </FormItem>
                <!--种类-->
                <!-- <FormItem :label="INIT_DATA.main.purchase_prod_class" prop="name">
                  <Input v-model="formItem.prodClass" :placeholder="INIT_DATA.main.tips_cate" clearable></Input>
                </FormItem> -->
                <FormItem :label="INIT_DATA.main.purchase_prod_class" prop="name">
                  <Row>
                      <Col span="7">
                        <FormItem>
                          <Select v-model="formItem.prodClass" @on-change="selectVal" placeholder="종류 선택">
                            <Option v-for="(item,index) in selectList1" :key="index" :value="item.cateId">{{item.cateName}}</Option>
                          </Select>
                        </FormItem>
                      </Col>
                      <Col span="4" style="text-align: center">
                        <Icon type="minus-round"></Icon>
                        <Icon type="minus-round"></Icon>
                        <Icon type="minus-round"></Icon>
                      </Col>
                      <Col span="7">
                        <FormItem>
                          <Select v-model="formItem.prodClassCode" placeholder="종류 선택">
                            <Option v-for="(item,index) in selectList2" :key="index" :value="item.cateId">{{item.cateName}}</Option>
                          </Select>
                        </FormItem>
                      </Col>
                  </Row>
                </FormItem>
                <!--计量单位-->
                <FormItem :label="INIT_DATA.main.purchase_unit" prop="unit">
                  <Input v-model="formItem.purchaseUnit" :placeholder="INIT_DATA.main.tips_unit" clearable></Input>
                </FormItem>
                <!--价格-->
                <FormItem :label="INIT_DATA.main.purchase_price + '(￥)'" prop="price">
                  <Row>
                    <Col span="7">
                    <FormItem prop="miniprice">
                      <Input v-model="formItem.miniPrice" :placeholder="INIT_DATA.main.tips_mini_money"
                      >
                      <span slot="append" v-show="formItem.purchaseUnit">위안/{{formItem.purchaseUnit}}</span>
                      </Input>
                    </FormItem>
                    </Col>
                    <Col span="4" style="text-align: center">
                    <Icon type="minus-round"></Icon>
                    <Icon type="minus-round"></Icon>
                    <Icon type="minus-round"></Icon>
                    </Col>
                    <Col span="7">
                    <FormItem prop="maxprice">
                      <Input v-model="formItem.maxPrice" :placeholder="INIT_DATA.main.tips_max_money">
                      <span slot="append" v-show="formItem.purchaseUnit">위안/{{formItem.purchaseUnit}}</span>
                      </Input>
                    </FormItem>
                    </Col>
                  </Row>
                </FormItem>
                <!--样品数量-->
                <FormItem :label="INIT_DATA.main.purchase_sample_number" prop="sampleNumber">
                  <Input v-model="formItem.sampleNumber" :placeholder="INIT_DATA.main.tips_eg" ref="num"
                  >
                  <span slot="append" v-show="formItem.purchaseUnit">{{formItem.purchaseUnit}}</span>
                  </Input>
                </FormItem>
                <!--购买总数量-->
                <FormItem :label="INIT_DATA.main.purchase_number" prop="totalNumber">
                  <Input v-model="formItem.totalNumber" :placeholder="INIT_DATA.main.tips_number">
                  <span slot="append" v-show="formItem.purchaseUnit">{{formItem.purchaseUnit}}</span>
                  </Input>
                </FormItem>
                <!--分割线-->
                <br>
                <hr style="width: 105%;background: #c3c8c6;border-top:none">
                <br><br>
                <!--产品颜色-->
                <FormItem :label="formItem.prodPrameters.data[0].paramName?formItem.prodPrameters.data[0].paramName:''"
                          prop="color">
                  <Input
                    v-model="formItem.prodPrameters.data[0].paramValue"
                    :placeholder="formItem.prodPrameters.data[0].paramName?formItem.prodPrameters.data[0].paramName:''"
                    clearable></Input>
                </FormItem>
                <!--产品大小-->
                <FormItem
                  :label="formItem.prodPrameters.data[1].paramName?formItem.prodPrameters.data[1].paramName:''"
                  prop="size">
                  <Input v-model="formItem.prodPrameters.data[1].paramValue"
                         :placeholder="formItem.prodPrameters.data[1].paramName?formItem.prodPrameters.data[1].paramName:''"
                         clearable></Input>
                </FormItem>
                <!--&lt;!&ndash;产品用途&ndash;&gt;-->
                <FormItem
                  :label="formItem.prodPrameters.data[2].paramName?formItem.prodPrameters.data[2].paramName:''"
                  prop="yongtu">
                  <Input v-model="formItem.prodPrameters.data[2].paramValue"
                         :placeholder="formItem.prodPrameters.data[2].paramName?formItem.prodPrameters.data[2].paramName:''"
                         clearable></Input>
                </FormItem>
                <!--添加参数-->
                <FormItem :label="INIT_DATA.main.purchase_parameter">
                  <Row>
                    <Col span="6">
                    <Button type="ghost" icon="plus" @click.native="addPram"
                            style="color: rgba(250,177,0,1);border-color: rgba(250,177,0,1)">
                      {{INIT_DATA.main.purchase_parameter_add}}
                    </Button>
                    </Col>
                  </Row>
                  <br>
                  <Row>
                    <Table :columns="formItem.prodPrameters.columns" :data="formItem.prodPrameters.data.slice(3)"
                           :show-header="false" :no-data-text=INIT_DATA.main.edit_param_default_tips>
                    </Table>
                  </Row>
                </FormItem>
                <FormItem :label="INIT_DATA.main.purchase_intro">
                  <Input v-model="formItem.tips" type="textarea" :autosize="{minRows: 2,maxRows: 5}"
                         :placeholder="INIT_DATA.main.tips_intro" clearable></Input>
                </FormItem>
                <!--上传图片-->
                <FormItem style="width: 800px;">
                  <div class="demo-upload-list" v-for="(item ,index) in uploadList" :key="index">
                    <template v-if="uploadList">
                      <img :src="item">
                      <div class="demo-upload-list-cover">
                        <Icon type="ios-eye-outline" size="40" @click.native="handleView(item)"></Icon>
                        <Icon type="ios-trash-outline" size="40" @click.native="handleRemove(index)"></Icon>
                      </div>
                    </template>
                    <template v-else>
                      <Progress v-if="item.showProgress" :percent="item.percentage" hide-info></Progress>
                    </template>
                  </div>
                  <Upload
                    ref="upload"
                    :show-upload-list="true"
                    :on-success="handleSuccess"
                    accept="image/*"
                    :max-size="20488"
                    :on-exceeded-size="handleMaxSize"
                    :before-upload="handleBeforeUpload"
                    multiple
                    type="drag"
                    action="http://xx.com"
                    style="display: inline-block;width:120px;"
                    v-show="isUpBtn"
                  >
                    <div style="width: 120px;height:120px;line-height: 148px;">
                      <Icon type="camera" size="50"></Icon>
                    </div>


                  </Upload>
                  <p>{{INIT_DATA.main.tips_upload}}</p>
                  <Modal v-model="visible" ok-text="확인" cancel-text="취소">
                    <p slot="header" style="text-align:center">
                      <Icon type="information-circled"></Icon>
                      <span>그림 미리보기</span>
                    </p>
                    <img :src="imgName" v-if="visible" style="width: 100%">
                    <!--<div slot="footer">-->
                    <!--</div>-->
                  </Modal>
                </FormItem>
                <Row type="flex" justify="start">
                  <Col span="4">
                  <Button long class="submit"
                          :disabled="!formItem.name||!formItem.maxPrice||!formItem.miniPrice||!formItem.prodClass||!formItem.prodClassCode||!formItem.totalNumber||!formItem.purchaseUnit||!formItem.sampleNumber||!formItem.prodPrameters.data[0].paramValue||!formItem.prodPrameters.data[1].paramValue||!formItem.prodPrameters.data[2].paramValue||!formItem.imgs.length"
                          :loading="submitStatus" @click="submit" style="margin-left: 102px">
                    {{INIT_DATA.main.purchase_button}}
                  </Button>
                  </Col>
                </Row>
              </Form>
              <Spin fix v-if="submitStatus"></Spin>
              </Col>
            </Row>
          </Card>
          </Col>
        </Row>
      </Content>
      <!--发布成功-->
      <Modal v-model="pubSuccess" @on-cancel="cancelPub">
        <p slot="header" style="text-align:center">
          <Icon type="checkmark-round"></Icon>
          <span>신청 성공</span>
        </p>
        <div style="text-align:center">
          축하합니다. 성공을 공개합니다.
        </div>
        <div slot="footer">
          <Button type="success" size="large" long @click="myStockUrl" class="loginBtn">확인
          </Button>
        </div>
      </Modal>
      <!--login-->
      <Modal v-model="noLogin" width="360" :mask-closable="false" class-name="loginModel" :closable="false">
        <p slot="header" style="text-align:center">
          <!--<Icon type="information-circled"></Icon>-->
          <span>먼저 로그인하십시오</span>
        </p>
        <Tabs value="SMS">
          <TabPane label="핸드폰인증번호등록" name="SMS">
            <div style="text-align:center">
              <Form label-position="left" :rules="ruleCustom" :label-width="80" :model="loginItem" class="loginCon">
                <FormItem label="핸드폰 번호" prop="phone">
                  <Row>
                    <Col span="22">
                    <Input type="text" placeholder="핸드폰 번호를 입력하십시오" v-model="loginItem.phone"></Input>
                    </Col>
                  </Row>
                </FormItem>
                <FormItem label="이미지 확인" prop="vImgCode">
                  <Row>
                    <Col span="11">
                    <Input type="text" placeholder="사진 인증 코드" v-model="loginItem.vImgCode" width="130px"></Input></Col>
                    <Col span="9" offset="3">
                    <!--图片验证码-->
                    <s-identify :identifyCode="identifyCode" @click.native="refreshCode"></s-identify>
                    </Col>
                  </Row>
                </FormItem>
                <FormItem label="인증 코드" prop="vcode">
                  <Row>
                    <Col span="11">
                    <Input type="text" placeholder="SMS 인증 코드를" v-model="loginItem.vcode" width="130px"></Input></Col>
                    <Col span="9" offset="3">
                    <Button class="getCodeBtn" :disabled="isGetCode||isGetCodee" @click="getCode"
                            v-show="isShowGetCode">인증 코드 받기
                    </Button>
                    <Button class="getCodeBtn" disabled v-show="isShowTimer">{{count}}</Button>
                    </Col>
                  </Row>
                </FormItem>
              </Form>
            </div>
            <div>
              <Button type="success" size="large" long @click="Login" class="loginBtn"
                      :disabled="!loginItem.phone||!loginItem.vcode||!loginItem.vImgCode">로그인
              </Button>
            </div>
          </TabPane>
          <TabPane label="QR코드식별등록" name="CODE">
            <div>
              <img :src="loginItem.loginErCodeImg" alt="" width="150px" height="150px"
                   style="margin: -10px auto 0 auto;display: inherit">
              <br>
              <p style="text-align: center">낮선이방문App을 사용하여 QR코드식별등록</p>
            </div>
          </TabPane>
        </Tabs>

        <div slot="footer" style="display: none">
          <p style="text-align: center"></p>
          <!--<Button type="success" size="large" long @click="Login" class="loginBtn"-->
          <!--:disabled="!loginItem.phone||!loginItem.vcode">로그인-->
          <!--</Button>-->
        </div>
      </Modal>
      <!--选择城市经理-->
      <Modal v-model="show.selManage" :mask-closable="false" :closable="false">
        <p slot="header" style="text-align: center"><span v-html="INIT_DATA.showSelManage.city_manage_title"
                                                          style="font-size: 24px"></span></p>
        <div>
          <Form :label-width="80">
            <FormItem :label="INIT_DATA.showSelManage.city_manage_owned_city">
              <Row :gutter="16">
                <Col span="11">
                <Select :placeholder="INIT_DATA.showSelManage.city_manage_select_city" clearable
                        @on-change="queryCityList">
                  <Option v-for="(item,index) in INIT_DATA.showSelManage.proList" :key="index" :value="item.code">
                    {{item.name}}
                  </Option>
                </Select>
                </Col>
                <Col span="11">
                <Select :placeholder="INIT_DATA.showSelManage.city_manage_select_city" clearable
                        :not-found-text="INIT_DATA.showSelManage.city_manage_select_city"
                        @on-change="queryCityMList">
                  <Option v-for="(item,index) in INIT_DATA.selCityList" :key="index" :value="item.code">{{item.name}}
                  </Option>
                </Select>
                </Col>
              </Row>
            </FormItem>
            <p>{{INIT_DATA.showSelManage.city_manage_query_select}}：<span style="color:#Fab100">{{INIT_DATA.managerList.length}}{{INIT_DATA.showSelManage.city_manage_unit}}</span>
            </p>
            <div class="mList">
              <Row type="flex" justify="space-between">
                <Col span="11" v-bind:class="{selCard:INIT_DATA.activeManger == i}" class="mCard"
                     v-for="(i,index) in INIT_DATA.managerList" @click.native="selectedManger(i)" :key="index">
                <Row type="flex" justify="space-between">
                  <Col span="13">
                  <div class="iblock">
                    <h3 class="showMName" v-html="i.manageName"></h3>
                    <span class="showMPhone" v-html="i.managePhone"></span>
                  </div>
                  </Col>
                  <Col span="8">
                  <div class="iblock">
                    <Avatar :src="i.manageHeadImg" style="width: 60px;height: 60px"/>
                  </div>
                  </Col>
                </Row>
                </Col>
              </Row>
            </div>
          </Form>
        </div>
        <div slot="footer">
          <Row type="flex" justify="center">
            <Col span="6" style="text-align: center">
            <Button style="width: 90%" @click.native="noselMang">{{INIT_DATA.showSelManage.city_manage_button_cancel}}
            </Button>
            </Col>
            <Col span="6" style="text-align: center">
            <Button :disabled="!INIT_DATA.isSelMang" @click.native="confrimMang"
                    style="width: 90%;background: rgba(250,177,0,1);color: #fff">
              {{INIT_DATA.showSelManage.city_manage_button_confirm}}
            </Button>
            </Col>
          </Row>
        </div>
      </Modal>
      <!--添加参数弹框-->
      <Modal v-model="show.isAddPram" :mask-closable="false" :closable="false">
        <p slot="header" style="text-align: center"><span v-html="INIT_DATA.addPrams.edit_param_title"
                                                          style="font-size: 24px"></span></p>
        <div>
          <Form :label-width="80">
            <FormItem :label="INIT_DATA.addPrams.edit_param_name">
              <Input v-model="addPrams.paramName" :placeholder="INIT_DATA.addPrams.edit_param_name_msg"></Input>
            </FormItem>
            <FormItem :label="INIT_DATA.addPrams.edit_param_value">
              <Input v-model="addPrams.paramValue" :placeholder="INIT_DATA.addPrams.edit_param_value_msg"></Input>
            </FormItem>
          </Form>
        </div>
        <div slot="footer">
          <Row type="flex" justify="center">
            <Col span="6" style="text-align: center">
            <Button style="width: 90%" @click.native="cancelAddPram">{{INIT_DATA.addPrams.edit_param_button_cancel}}
            </Button>
            </Col>
            <Col span="6" style="text-align: center">
            <Button :disabled="!addPrams.paramName||!addPrams.paramValue" @click.native="confrimAddPram"
                    style="width: 90%;background: rgba(250,177,0,1);color: #fff">
              {{INIT_DATA.addPrams.edit_param_button_confirm}}
            </Button>
            </Col>
          </Row>
        </div>
      </Modal>
      <!--批量发布弹框-->
      <Modal v-model="show.isBatch" :mask-closable="false" :closable="false" width="580px">
        <p slot="header" style="text-align: center"><span v-html="INIT_DATA.Batch.batch_title"
                                                          style="font-size: 24px"></span></p>
        <div style="box-sizing: border-box;padding: 11px">
          <p>1. 시장조사의뢰신청 양식 다운로드  구매상품 분류표 다운로드
            <div style="margin: 15px 0">
              <Button type="ghost" style="margin-left: 20px;color: rgb(250, 177, 0);border-color: rgb(250, 177, 0)"
                    @click="downLoadTemp"><i
              class="iconfont icon-xiazai" style="line-height: 100%;vertical-align: middle"></i>{{INIT_DATA.Batch.batch_download_button}}
            </Button>
            <Button type="ghost" style="margin-left: 20px;color: rgb(250, 177, 0);border-color: rgb(250, 177, 0)"
                    @click="downLoadTemp2"><i
                class="iconfont icon-xiazai" style="line-height: 100%;vertical-align: middle"></i>{{INIT_DATA.Batch.batch_download_button}}
              </Button>
            </div>
          </p>
          <p style="line-height: 40px">2.시장조사를 의뢰하실때 구매상품 분류표 중의 대, 중 분류 편성번호를 구매의뢰신청 양식 파일의 대, 중 분류 편성번호칸에 기입해주세요.</p>
          <p>
            <!--<i class="iconfont icon-XLS"-->
            <!--style="color: #35BA71;font-size: 24px"></i>-->
            <Input disabled v-model="formItem.batchName"><i class="iconfont icon-XLS"
                                                            style="color: #35BA71;font-size: 24px"></i>
            <label for="batch" slot="append" style="cursor: pointer">{{INIT_DATA.Batch.batch_upload_button}}</label>
            <input style="display: none" type="file" @change="getBatchFile" id="batch" slot="append" ref="excelFiles"
                   accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"></input>
            </Input>
          </p>
          <p style="margin-top: 14px;color: #FF574D">신청 양식 파일에 있는 칸의 위치나 글자를 변경하지 마세요.</p>
          <p style="margin-top: 20px" v-show="!show.isHaveCityUserId">3.{{INIT_DATA.Batch.city_manage_title}}</p>
          <Select clearable style="margin-top: 10px" :placeholder="INIT_DATA.Batch.batch_select_title"
                  v-model="formItem.cityUserId" v-show="!show.isHaveCityUserId">
            <Option v-for="(i,index) in INIT_DATA.Batch.userlist" :key="index" :value="i.manageId">
              {{i.manageNickName}}
            </Option>
          </Select>
        </div>
        <div slot="footer">
          <Row type="flex" justify="center">
            <Col span="6" style="text-align: center">
            <Button style="width: 90%" @click.native="cancelBatch">{{INIT_DATA.Batch.batch_cancel_button}}
            </Button>
            </Col>
            <Col span="6" style="text-align: center">
            <Button :loading="show.isBatchIng" :disabled="!formItem.batchFile"
                    @click.native="confrimBatch"
                    style="width: 90%;background: rgba(250,177,0,1);color: #fff">
              {{INIT_DATA.Batch.batch_confirm_button}}
            </Button>
            </Col>
          </Row>
        </div>
      </Modal>
      <Footer class="FT">
        <Row type="flex" justify="center">
          <Col span="18">
          <Row type="flex" justify="center">
            <Col span="16">
            <!--<h2>Iambuyer</h2>-->
            <p>담당자 이메일：zhaojing03@hc360.com</p>
            <p>회사주소：북경시 창평구 회룡관 치리추이 후이총원</p>
            <p>Copyright @2018 저작권은북경 후이총인터넷기술유한공사베이징 ICP16014314호</p>
            </Col>
            <Col span="8">
            <!--<Card :bordered="false" class="qrCard">-->
            <!--<img-->
            <!--src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1515691681335&di=c555957f874f275187d644769a78bd6c&imgtype=0&src=http%3A%2F%2Fsrc.house.sina.com.cn%2Fimp%2Fimp%2Fdeal%2F86%2F68%2F4%2Fe51eac8a98c2bd65c6b68bae86c_p1_mk1_wm35.gif"-->
            <!--alt="">-->
            <!--<h5>QR코드를 스캔하고</h5>-->
            <!--<h5>모바일 단말기에서 구매 정보를 즉시 신청하십시오</h5>-->
            <!--</Card>-->
            </Col>
          </Row>
          </Col>
        </Row>

      </Footer>
    </Layout>

  </div>
</template>
<script type="text/ecmascript-6">
  import {getObjectURL, getCookieVal, setCookie, delCookie, getGVerify} from '@/api/tool'
  import {_initPCPublish, _initPCShowSelManage, _getCode, _verifCode, _purchAdd, _upLoadImg, ERROK} from '@/api/init'
  import * as F from '@/api/init'
  import {mapMutations, mapGetters} from 'vuex'
  import lrz from 'lrz'
  import sIdentify from '../plugins/identify'

  export default {
    data() {
      //表单验证
      const isPhone = (rule, value, callback) => {
        const r = /^[0-9]*$/
        if (!value || value.length !== 11 || !r.test(value)) {
          callback(new Error(this.INIT_DATA.main.tips_error))
          // this.isGetCode = true
        } else {
          callback()
          // this.isGetCode = false
        }
      }
      const isCode = (rule, value, callback) => {
        if (!value || value.length !== 4) {
          callback(new Error(this.INIT_DATA.main.tips_error))
          this.loginItem.vcode = ''
        } else {
          callback()
        }
      }
      const vImgCode = (rule, value, callback) => {
        if (!value || value !== this.identifyCode) {
          callback(new Error(this.INIT_DATA.main.tips_error))
          this.loginItem.vImgCode = ''
          this.isGetCode = true
        } else {
          this.isGetCode = false
          callback()
        }
      }
      const isSampleNumber = (rule, value, callback) => {
        const r = /^[0-9]*$/
        if (!r.test(this.formItem.sampleNumber) || !this.formItem.sampleNumber) {
          callback(new Error(this.INIT_DATA.main.tips_error))
          this.formItem.sampleNumber = ''
        } else if (this.formItem.sampleNumber.length > 11) {
          callback(new Error(this.INIT_DATA.main.tips_error))
          this.formItem.sampleNumber = ''
        } else {
          callback()
        }
      }
      const isTotalNumber = (rule, value, callback) => {
        const r = /^[0-9]*$/
        if (!r.test(this.formItem.totalNumber) || !this.formItem.totalNumber) {
          callback(new Error(this.INIT_DATA.main.tips_error))
          this.formItem.totalNumber = ''
        } else if (this.formItem.totalNumber.length > 11) {
          callback(new Error(this.INIT_DATA.main.tips_error))
          this.formItem.totalNumber = ''
        } else {
          callback()
        }
      }
      const isminiPrice = (rule, value, callback) => {
        const r = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/
        if (!r.test(this.formItem.miniPrice) || !this.formItem.miniPrice) {
          callback(new Error(this.INIT_DATA.main.tips_error))
        } else if (this.formItem.miniPrice.length > 11) {
          callback(new Error(this.INIT_DATA.main.tips_error))
          this.formItem.miniPrice = ''
        } else {
          callback()
        }
      }
      const ismaxPrice = (rule, value, callback) => {
        const r = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/
        if (!r.test(this.formItem.maxPrice) || !this.formItem.maxPrice) {
          callback(new Error(this.INIT_DATA.main.tips_error))
        } else if (this.formItem.maxPrice.length > 11) {
          callback(new Error(this.INIT_DATA.main.tips_error))
          this.formItem.maxPrice = ''
        } else {
          callback()
        }
      }
      const isName = (rule, value, callback) => {
        if (!this.formItem.name) {
          callback(new Error(this.INIT_DATA.main.tips_error))
        } else if (this.formItem.name.length >= 30) {
          callback(new Error(this.INIT_DATA.main.tips_error))
          this.formItem.name = ''
        } else {
          callback()
        }
      }
      const isColor = (rule, value, callback) => {
        if (!this.formItem.prodPrameters.data[0].paramValue) {
          callback(new Error(this.INIT_DATA.main.tips_error))
        } else if (this.formItem.prodPrameters.data[0].paramValue.length >= 30) {
          callback(new Error(this.INIT_DATA.main.tips_error))
          this.formItem.prodPrameters.data[0].paramValue = ''
        } else {
          callback()
        }
      }
      const isSize = (rule, value, callback) => {
        if (!this.formItem.prodPrameters.data[1].paramValue) {
          callback(new Error(this.INIT_DATA.main.tips_error))
        } else if (this.formItem.prodPrameters.data[1].paramValue.length >= 30) {
          callback(new Error(this.INIT_DATA.main.tips_error))
          this.formItem.prodPrameters.data[1].paramValue = ''
        } else {
          callback()
        }
      }
      const isYongtu = (rule, value, callback) => {
        if (!this.formItem.prodPrameters.data[2].paramValue) {
          callback(new Error(this.INIT_DATA.main.tips_error))
        } else if (this.formItem.prodPrameters.data[2].paramValue.length >= 30) {
          callback(new Error(this.INIT_DATA.main.tips_error))
          this.formItem.prodPrameters.data[2].paramValue = ''
        } else {
          callback()
        }
      }
      const isUnit = (rule, value, callback) => {
        if (!this.formItem.purchaseUnit) {
          callback(new Error(this.INIT_DATA.main.tips_error))
        } else if (this.formItem.purchaseUnit.length >= 10) {
          callback(new Error(this.INIT_DATA.main.tips_error))
          this.formItem.purchaseUnit = ''
        } else {
          callback()
        }
      }
      return {
        //图片验证码
        identifyCodes: '1234567890',
        identifyCode: '',
        INIT_DATA: {
          main: '',
          showSelManage: '',
          addPrams: {
            edit_param_button_del: '',
            edit_param_button_edit: ''
          },
          selCityList: [],
          managerList: [],
          activeManger: '',
          Batch: '',
          isSelMang: false,
        },
        selectList1: [], // 一级下拉
        selectList2: [], // 二级下拉
        canshu: [{paramName: '제품 컬러', paramValue: ''},
          {paramName: '제품 사이즈', paramValue: ''},
          {paramName: '제품 용도', paramValue: ''}],
        formItem: {
          cityUserId: getCookieVal('mid') == null ? '' : getCookieVal('mid'),
          name: '',
          prodClass: '',
          prodClassCode: '',
          sampleNumber: '',
          totalNumber: '',
          miniPrice: '',
          maxPrice: '',
          purchaseUnit: '',
          color: '',
          size: '',
          yongtu: '',
          prodPrameters: {
            columns: [
              {
                title: 'Name',
                key: 'paramName'
              },
              {
                title: 'Value',
                key: 'paramValue'
              },
              {
                title: 'Action',
                key: 'action',
                width: 150,
                align: 'center',
                render: (h, params) => {
                  return h('div', [
                    h('Button', {
                      props: {
                        type: 'primary',
                        size: 'small'
                      },
                      style: {
                        marginRight: '5px',
                        backgroundColor: '#02C2A2',
                        borderColor: '#02C2A2'
                      },
                      on: {
                        click: () => {
                          this.show.isEditPramIndex = params.index + 3
                          this.addPram()
                          this.show.isAddPram = true
                          this.addPrams.paramName = params.row.paramName
                          this.addPrams.paramValue = params.row.paramValue
                        }
                      }
                    }, this.INIT_DATA.main.edit_param_button_edit),
                    h('Button', {
                      props: {
                        type: 'error',
                        size: 'small'
                      },
                      style: {
                        backgroundColor: '#FAB100',
                        borderColor: '#FAB100'
                      },
                      on: {
                        click: () => {
                          this.show.isEditPramIndex = params.index + 3
                          this.formItem.prodPrameters.data.splice(this.show.isEditPramIndex, 1)
                          this.show.isEditPramIndex = ''
                        }
                      }
                    }, this.INIT_DATA.main.edit_param_button_del)
                  ]);
                }
              }
            ],
            data: [
              {paramName: '제품 컬러', paramValue: ''},
              {paramName: '제품 사이즈', paramValue: ''},
              {paramName: '제품 용도', paramValue: ''}
            ],
          },
          tips: '',
          batchFile: '',
          batchName: '',
          imgs: []
        },
        uploadList: [],
        addPrams: {
          paramName: '',
          paramValue: ''
        },
        show: {
          selManage: false,
          isAddPram: false,
          isEditPramIndex: '',
          isHaveCityUserId: getCookieVal('mid') ? true : false,
          isBatch: false,
          isBatchIng: false,
          isDelImg: false
          // isClickBatch: this.formItem.cityUserId === "" ? this.show.isClickBatch = false : this.show.isClickBatch = true
        },
        erCodeTimer: '',
        vCodeTimer: '',
        user: getCookieVal('tel') || this.loginCode,
        count: '',
        /*城市经理列表*/
        manageList: '',
        /*是否显示上传图片按钮*/
        isUpBtn: true,
        submitStatus: false,
        isSubmit: false,
        isGetCode: true,
        isGetCodee: true,
        isShowGetCode: true,
        isShowTimer: false,
        file: '',
        imgName: '',
        noLogin: false,
        isLoginIng: false,
        visible: false,
        pubSuccess: false,
        delImgList: [false, false, false],
        loginPhone: '',
        loginCode: '',
        imgFile: '',
        FDNAME: [
          {'name': ''},
          {'name': ''},
          {'name': ''}
        ],
        loginItem: {
          phone: '',
          vcode: '',
          vImgCode: '',
          userType: getCookieVal('mid'),
          uid: this.$route.query.userId || getCookieVal('uid'),
          loginErCodeImg: '',
          uuid: ''
        },
        ruleCustom: {
          phone: [
            {validator: isPhone, trigger: 'blur'}
          ],
          vcode: [
            {validator: isCode, trigger: 'change'}
          ],
          vImgCode: [
            {validator: vImgCode, trigger: 'change'}
          ]
        },
        rulePublish: {
          manager: [{required: false}],
          price: [{required: true}],
          color: [{required: true, validator: isColor, trigger: 'change'}],
          size: [{required: true, validator: isSize, trigger: 'change'}],
          yongtu: [{required: true, validator: isYongtu, trigger: 'change'}],
          unit: [
            {required: true, validator: isUnit, trigger: 'change'},
          ],
          sampleNumber: [
            {required: true, validator: isSampleNumber, trigger: 'change'}
          ],
          totalNumber: [
            {required: true, validator: isTotalNumber, trigger: 'change'}
          ],
          miniprice: [
            {required: true, validator: isminiPrice, trigger: 'change'}
          ],
          maxprice: [
            {required: true, validator: ismaxPrice, trigger: 'change'}
          ],
          name: [
            {required: true, validator: isName, trigger: 'change'}
          ]
        }
      }
    },
    components: {
      sIdentify
    },
    mounted() {
      this.identifyCode = "";
      this.makeCode(this.identifyCodes, 4);
    },
    beforeCreate() {
      if (this.$route.query.isexit == 1) {
        delCookie('tel')
        delCookie('mid')
        this.$router.push(this.$route.path)
      } else if (this.$route.query.isexit == 0) {
        setCookie('tel', this.$route.query.phone)
      }
    },
    created() {
      F._initPCPublish(this.languages).then(res => {
        if (res.status = ERROK) {
          // this.$nextTick(function () {
          this.INIT_DATA.main = res.data
          if (this.$route.query.phone && this.$route.query.purchId) {
            F._editPurch(this.$route.query.purchId, this.$route.query.phone, this.languages).then(res => {
                if (res.status === F.ERROK) {
                  console.log(res.data)
                  this.show.isHaveCityUserId = true
                  this.formItem.name = res.data.purchaseName
                  this.formItem.prodClass = res.data.purchaseClass
                  this.formItem.prodClassCode = res.data.purchaseClassCode
                  this.formItem.totalNumber = res.data.purchaseBuyNumber
                  this.formItem.sampleNumber = res.data.purchaseExampleNumber
                  this.formItem.maxPrice = res.data.purchaseMaxPrice
                  this.formItem.miniPrice = res.data.purchaseMixPrice
                  this.formItem.tips = res.data.purchaseInstruc
                  this.formItem.purchaseUnit = res.data.purchaseUnit
                  this.uploadList = res.data.imgs
                  for (let i = 0; i < res.data.imgs.length; i++) {
                    this.formItem.imgs.push(res.data.imgs[i])
                  }
                  if (res.data.purchaseParameters == null) {
                    this.formItem.prodPrameters.data = this.canshu
                  } else {
                    this.formItem.prodPrameters.data = JSON.parse(res.data.purchaseParameters)
                    let cs = JSON.parse(res.data.purchaseParameters)
                    switch (cs.length) {
                      case 1:
                        this.formItem.prodPrameters.data = this.formItem.prodPrameters.data.concat(this.canshu.slice(1))
                        break;
                      case 2:
                        this.formItem.prodPrameters.data = this.formItem.prodPrameters.data.concat(this.canshu.slice(2))
                        break;

                    }
                  }

                  // res.data.purchaseImage01HttpUrl !== null ? this.uploadList.push({'url': res.data.purchaseImage01HttpUrl}) : ''
                  // res.data.purchaseImage02HttpUrl !== null ? this.uploadList.push({'url': res.data.purchaseImage02HttpUrl}) : ''
                  // res.data.purchaseImage03HttpUrl !== null ? this.uploadList.push({'url': res.data.purchaseImage03HttpUrl}) : ''
                  this.uploadList.length == 10 ? this.isUpBtn = false : ''

                  // const FDNAME = this.FDNAME
                  // const uploadList = this.uploadList
                  // // for(let i = 0;i < uploadList.length;i++){
                  // switch (uploadList.length) {
                  //   case 3:
                  //     break
                  //   case 2:
                  //     FDNAME.splice(1, 1)
                  //     break
                  //   case 1:
                  //     FDNAME.splice(0, 2)
                  //     break
                  //   case 0:
                  //     FDNAME.splice(0, 3)
                  //     break
                  //
                  // }

                  // }
                  // this.INIT_DATA.addPrams.
                }
              }
            )
          }
          // })

        }
      })
      if (!getCookieVal('tel')) {
        this.topLogin()
      }
      if (this.loginItem.userType == null) {
        this.loginItem.userType = 0
      }
      F._pcInit(getCookieVal('tel')).then(res => {
        if (res.data.content === '2') {
          this.show.isHaveCityUserId = true
        }
      })
      // 一级下拉
      this.getOneSelect();
    },
    computed: {
      phone() {
        return this.loginItem.phone
      },
      ...mapGetters([
        'languages'
      ])
    },
    watch: {
      // 'loginItem.userType':{
      //   handler:(val,oldVal) =>{
      //    if(this.loginItem.userType == ''){
      //      this.loginItem.userType = 0
      //    }
      //   }
      //
      // },
      phone(newValue, oldValue) {
        const r = /^[0-9]*$/
        if (newValue.toString().length == 11 && r.test(newValue)) {
          this.isGetCodee = false
        } else {
          this.isGetCodee = true
        }
      },
      noLogin() {
        if (!this.noLogin) {
          clearInterval(window.vCodeTimer)
          clearInterval(this.erCodeTimer)
          window.vCodeTimer = null
          window.erCodeTimer = null
        } else if (this.noLogin) {
          this.topLogin()
        }
      }
    },
    methods: {
      ...mapMutations({
        getLanguage: 'SET_LANGUAGE'
      }),
      /**
       * 图片验证码相关
       * **/
      randomNum(min, max) {
        return Math.floor(Math.random() * (max - min) + min);
      },
      refreshCode() {
        this.identifyCode = "";
        this.makeCode(this.identifyCodes, 4);
      },
      makeCode(o, l) {
        for (let i = 0; i < l; i++) {
          this.identifyCode += this.identifyCodes[
            this.randomNum(0, this.identifyCodes.length)
            ];
        }
        // console.log(this.identifyCode);
      },
      /**
       * 提交批量发布
       * **/
      confrimBatch() {
        if (!getCookieVal('tel')) {
          this.topLogin()
        } else {
          this.show.isBatchIng = true
          F._purchBatch(getCookieVal('tel'), this.loginItem.userType, this.formItem.batchFile).then(res => {
            console.log(res)
            if (res.data.ret == F.ERROK) {
              this.show.isBatchIng = false
              this.cancelBatch()
              this.$Notice.success({title: this.INIT_DATA.Batch.batch_result_success})
              setCookie('mid', this.formItem.cityUserId)
            } else {
              this.show.isBatchIng = false
              this.cancelBatch()
              this.$Notice.error({title: this.INIT_DATA.Batch.batch_result_fail})
            }
          })
        }

      },
      /**
       * 发布成功提示框取消操作
       * **/
      cancelPub() {
        this.formItem.name = ''
        this.formItem.prodClass = ''
        this.formItem.prodClassCode = ''
        this.formItem.miniPrice = ''
        this.formItem.maxPrice = ''
        this.formItem.sampleNumber = ''
        this.formItem.totalNumber = ''
        this.formItem.tips = ''
        this.uploadList = []
        this.FDNAME = []
        this.isUpBtn = true
        // this.formItem.prodPrameters.data[] = []
        for(let i = 0;i < this.formItem.prodPrameters.data.length;i++){
          this.formItem.prodPrameters.data[i].paramValue = ''
          this.formItem.prodPrameters.data.splice(3)
        }
        this.formItem.purchaseUnit = ''
        this.formItem.imgs = []
      },
      /**
       * 下载发布模板
       * **/
      downLoadTemp() {
        // window.open(this.INIT_DATA.Batch.batch_sample_download_url)
        window.location.href = this.INIT_DATA.Batch.batch_sample_download_url
      },
      downLoadTemp2() {
        // window.open(this.INIT_DATA.Batch.batch_sample_download_url)
        window.location.href = 'http://iambuyer.com/template/purchase-proType.xlsx'
      },
      /**
       * 取消批量发布
       * **/
      cancelBatch() {
        this.show.isBatch = false
        this.formItem.batchFile = ''
        this.formItem.batchName = ''
        this.$refs.excelFiles.value = ''
      },
      /**
       * 获取批量发布的文件
       * **/
      getBatchFile(e) {
        //`<i class="iconfont icon-XLS" style="color: #35BA71;font-size: 24px"></i>` +
        this.formItem.batchName = e.target.files[0].name
        let fomDat = new FormData()
        fomDat.append('file', e.target.files[0])
        this.formItem.batchFile = fomDat
      },
      /**
       * 批量发布初始化
       * **/
      Batch() {
        this.show.isBatch = true
        F._initBatch(this.languages).then(res => {
          if (res.status === F.ERROK) {
            this.INIT_DATA.Batch = res.data
          }
        })
      },
      /**
       * 取消添加参数
       * **/
      cancelAddPram() {
        this.show.isAddPram = false
        this.show.isEditPramIndex = ''
      },
      /**
       * 确定添加或者修改参数
       **/
      confrimAddPram() {
        this.show.isAddPram = false
        /*添加参数*/
        console.log(this.show.isEditPramIndex)
        if (this.show.isEditPramIndex === '') {
          this.formItem.prodPrameters.data.push({
            'paramName': this.addPrams.paramName,
            'paramValue': this.addPrams.paramValue
          })
        } else {
          /*修改参数*/
          this.formItem.prodPrameters.data[this.show.isEditPramIndex].paramName = this.addPrams.paramName
          this.formItem.prodPrameters.data[this.show.isEditPramIndex].paramValue = this.addPrams.paramValue
          this.show.isEditPramIndex = ''
        }

      },
      /**
       * 添加参数初始化
       * **/
      addPram() {
        this.addPrams.paramName = ''
        this.addPrams.paramValue = ''
        F._initAddPram(this.languages).then(res => {
          if (res.status === F.ERROK) {
            this.INIT_DATA.addPrams = res.data
            this.show.isAddPram = true
          }

        })
      },
      /**
       * 选择城市经理
       * **/
      selectedManger(i) {
        this.INIT_DATA.activeManger = i
        this.INIT_DATA.isSelMang = true
      },
      /**
       * 确定城市经理
       * **/
      confrimMang() {
        this.show.selManage = false
        this.INIT_DATA.isSelMang = this.show.selManage
        this.formItem.cityUserId = this.INIT_DATA.activeManger.manageId
        // this.show.isHaveCityUserId = true
      },
      /**
       * 取消选择城市经理
       * **/
      noselMang() {
        this.show.selManage = false
        this.INIT_DATA.activeManger = ''
      },
      /**
       * 查询某个省下城市与城市经理
       * **/
      queryCityList(pcode) {
        F._selCity(pcode).then(res => {
          if (res.status === F.ERROK) {
            this.INIT_DATA.selCityList = res.data
            this.INIT_DATA.managerList.length === 0 ? this.INIT_DATA.isSelMang = false : ''
            F._selProM(pcode).then(res => {
              if (res.status === F.ERROK) {
                this.INIT_DATA.managerList = res.data
              }
            })
          }
        })
      },
      /**
       * 查询某个城市下的城市经理
       * **/
      queryCityMList(Mlist) {
        F._selCityM(Mlist).then(res => {
          if (res.status === F.ERROK) {
            this.INIT_DATA.managerList = res.data
            this.INIT_DATA.managerList.length === 0 ? this.INIT_DATA.isSelMang = false : ''
          }
        })
      },
      /**
       * 显示选择城市经理对话框
       * **/
      showSelManage() {
        F._initPCShowSelManage(this.languages).then(res => {
          if (res.status === ERROK) {
            this.$nextTick(function () {
              this.show.selManage = true
              this.INIT_DATA.showSelManage = res.data
              this.INIT_DATA.managerList = res.data.userlist
            })

          } else {
            this.$Message.error(res.statusText);
          }
        })
      },
      /**
       * 我的采购
       * **/
      myStockUrl() {
        this.pubSuccess = false
        if (!getCookieVal('tel')) {
          this.noLogin = true
        } else {
          window.location.href = `http://korea.iambuyer.com/buyer/stProduct/listByBuyId?phone=${this.user || getCookieVal('tel')}&userId=${+this.formItem.cityUserId}&language=ko`
        }
      },
      /**
       * 我的个人中心首页
       * **/      myIndex() {
        this.pubSuccess = false
        if (!getCookieVal('tel')) {
          this.noLogin = true
        } else {
          window.location.href = `http://korea.iambuyer.com/buyer/stProduct/index?phone=${this.user || getCookieVal('tel')}&userId=${+this.formItem.cityUserId}&language=ko`
        }
      },
      /*显示登录窗口*/
      topLogin() {
        this.noLogin = true
        this.getErCode()
        window.erCodeTimer = setInterval(() => {
          this.getErCode()
          return 66
        }, 60000)
        window.vCodeTimer = setInterval(() => {
          console.log(this.loginItem.uuid)
          F._vErCode(this.loginItem.uuid).then(res => {
            console.log(res.data)
            if (res.data.ret == 200 && res.data.content !== '') {
              setCookie('tel', res.data.content)
              clearInterval(window.vCodeTimer)
              clearInterval(window.erCodeTimer)
              this.$Message.success({
                content: '로그인 성공',
                onClose: function () {
                  this.noLogin = false
                  F._usePhoneGetCityId(res.data.content).then((r) => {
                    r.cityUserId !== 'null' ? setCookie('mid', r.cityUserId) : ''
                    location.reload()
                  })
                  // location.reload()
                  // this.$router.push('/')
                }
              });

            }
          })
          return 68
        }, 5000)
      },
      /*
      * 获取登录二维码
      * */
      getErCode() {
        F._getLoginErCode().then(res => {
          this.loginItem.uuid = res.r.headers.uuid
          this.loginItem.loginErCodeImg = res.code
        })
      },
      /**
       * 提交发布采购
       * **/
      submit() {
        if (!getCookieVal('tel')) {
          this.noLogin = true
        } else {
          this.submitStatus = true
          this.$Loading.start()
          this.$Message.loading({
            content: '제출...',
            duration: 0,
            closable: true
          })
          this.formItem.imgs = this.formItem.imgs.join("&&")
          this.phurAdd()
          // if(!this.$route.query.purchId){
          //   this.formItem.imgs = this.formItem.imgs.join("&&")
          //   this.phurAdd()
          // }else {
          //   this.formItem.imgs = this.uploadList
          //   console.log('编辑重新发布')
          // }

        }
      },
      /**
       * 发布采购入口
       * **/
      phurAdd() {
        F._purchAdd(getCookieVal('tel'), this.formItem.prodClass, this.formItem.prodClassCode, this.formItem.name, this.formItem.totalNumber, this.formItem.maxPrice, this.formItem.miniPrice, this.formItem.sampleNumber, this.formItem.tips, this.formItem.purchaseUnit, this.formItem.imgs, this.formItem.cityUserId, this.formItem.prodPrameters.data, this.$route.query.purchId).then(res => {
          if (res.data.resultValue === '1') {
            this.submitStatus = false
            this.$Loading.finish()
            this.$Message.destroy()
            this.formItem.name = ''
            this.formItem.num = ''
            this.formItem.price = ''
            this.formItem.tips = ''
            this.uploadList = [],
              this.FDNAME = [],
              this.isUpBtn = true
            this.pubSuccess = true
            setCookie('mid', this.formItem.cityUserId)
//              setTimeout("this.myStockUrl()", 3000)
          }
        })
      },
      /***
       * 登录入口
       * ***/
      Login() {
        _verifCode(this.loginItem.phone, this.loginItem.vcode).then(res => {
          // this.$route.query.isexit == 1 ? console.log(this.$route.query.isexit) : console.log(this.$route.query.isexit)
          if (res.data.result == '1') {
            console.log(res)
            //非采购商不能发布采购并提示
            this.loginItem.userType = res.data.userType
            // if (res.data.userType !== '2'||'3') {
            //   this.$Notice.warning({
            //     title: '접속불가',
            //     desc: '당신은 구매자 아닙니다. 조사접수은 안 됩니다.'
            //   })
            //   this.noLogin = false
            //   this.loginItem.vcode = ''
            //   this.loginItem.phone = ''
            //   clearInterval(this.timer)
            //   this.isShowGetCode = true
            //   this.isShowTimer = false
            // } else {
            clearInterval(this.timer)
            setCookie('tel', this.loginItem.phone)
            setCookie('uid', this.loginItem.uid)
            res.data.cityUserId !== 'null' ? setCookie('mid', res.data.cityUserId) : ''
            res.data.cityUserId !== 'null' ? this.show.isHaveCityUserId = true : this.show.isHaveCityUserId = false
            this.loginItem.userType = res.data.cityUserId
            this.loginPhone = this.loginItem.phone

            res.data.cityUserId === 'null' ? this.formItem.cityUserId = 0 : this.formItem.cityUserId = res.data.cityUserId

            this.$Notice.success({
              title: '로그인 성공！',
              duration: 1,
              onClose:function () {
                location.reload()
              }
            })
            this.noLogin = false
            this.isShowGetCode = true
            this.isShowTimer = false
            this.loginItem.vcode = ''
            this.loginItem.phone = ''
            // if (this.formItem.name !== '' && this.formItem.num !== '' && this.formItem.price !== '') {
            //   this.submit()
            // }
            // }

          } else {
            this.loginItem.vcode = ''
            this.$Message.error(res.data.message)
          }
        })
      },
      /**
       * 退出登录
       * */
      esc() {
        this.loginPhone = ''
        this.user = ''
        delCookie('tel')
        delCookie('mid')
        location.reload()
        this.$router.push('/')
      },
      /**
       * 获取验证码
       * **/
      getCode() {
        this.isShowGetCode = false
        _getCode(this.loginItem.phone).then(res => {
          if (res.data.result === '1') {
            this.$Message.success('발송 성공')
            const TIME_COUNT = 60
            if (!this.timer) {
              this.count = TIME_COUNT
              this.isShowGetCode = false
              this.isShowTimer = true
              this.timer = setInterval(() => {
                if (this.count > 0 && this.count <= TIME_COUNT) {
                  this.count--
                  this.isShowTimer = true
                } else {
                  this.isShowGetCode = true
                  this.isShowTimer = false
                  clearInterval(this.timer)
                  this.timer = null
                }
              }, 1000)
            }
          } else {
            this.$Message.error('발송 실패')
          }
        })
      },
      handleView(name) {
        this.imgName = name;
        this.visible = true;
      },
      /**
       * 删除已选择待上传的图片
       * **/
      handleRemove(index) {
        this.formItem.imgs.splice(index, 1)
        this.uploadList.splice(index, 1)
        this.FDNAME.splice(index, 1, {name: ''})
        //是否删除图片
        this.show.isDelImg = true
        this.delImgList[index] = true
        const check = this.uploadList.length < 10
        if (check) {
          this.isUpBtn = true
        }
      },
      handleSuccess(res, file) {
        file.url = 'https://o5wwk8baw.qnssl.com/7eb99afb9d5f317c912f08b5212fd69a/avatar';
        file.name = '7eb99afb9d5f317c912f08b5212fd69a';
      },
      handleMaxSize(file) {
        this.$Notice.warning({
          title: 'Exceeding file size limit',
          desc: 'File  ' + file.name + ' is too large, no more than 2M.'
        });
      },
      /**
       * 图片上传
       * **/
      handleBeforeUpload(file) {
        console.log({a: this.formItem.imgs})
        this.$Loading.start()
        this.submitStatus = true
        lrz(file).then((res) => {
          this.imgFile = res.file
          let formData = new FormData()
          formData.append('file', this.imgFile)
          formData.append('systemName', 'iambuyerKor')
          _upLoadImg(formData).then(res => {
            if (res.status === ERROK) {
              this.uploadList.push(res.data.httpUrl)
              this.$Loading.finish()
              this.submitStatus = false
              if (!this.$route.query.purchId) {
                this.formItem.imgs.push(res.data.name)
              } else {
                //如果拉取的详情不等于0
                if (this.uploadList.length !== 0) {
                  // for(let i = 0;i < ){}
                  this.formItem.imgs.push(res.data.name)
                }
              }

              // if (this.show.isDelImg) {
              //   //如果删除过图片
              //   const delImgList = this.delImgList
              //   const FDNAME = this.FDNAME
              //   for (let i = 0; i < delImgList.length; i++) {
              //     delImgList[i] === true ? FDNAME[i].name = res.data.name : ''
              //   }
              // } else {
              //   //如果没删除过图片
              //   this.FDNAME.push({name: res.data.name})
              // }
            }
          })
        })
        const check = this.uploadList.length < 9
        if (!check) {
          this.$Notice.info({
            title: '최대 10 개 업로드'
          })
          this.isUpBtn = false
        }
//        return check;
        return false
      },

      // 一级菜单获取
      getOneSelect() {
        F._getOneSelect().then((res) => {
          console.log(res);
          this.selectList1 = res;
        })
      },
      // 二级菜单获取
      getTwoSelect(id) {
        F._getTwoSelect(id).then((res) => {
          console.log(res);
          this.selectList2 = res;
        })
      },
      selectVal() {
        console.log(this.formItem.prodClass);
        this.selectList2 = [];
        this.getTwoSelect(this.formItem.prodClass);
      }
    }
  }
</script>
<style lang="stylus" rel="stylesheet/stylus" scoped>
  @import "../../common/stylus/index.styl"
  .userPhone
    color #fff

  .ivu-table-header
    display none
    background #fff

  .content
    width 100%
    padding 0 50px
    margin 84px auto 20px auto

  .selManBor
    border 1px solid #e2e2e2
    border-radius 4px
    max-width 280px
    /*height 80px*/
    cursor pointer
    margin-top -22px
    a
      color $color-base
      display block
      text-align center
      line-height 80px
      font-size 18px
    .mCard
      margin-bottom 0px

  .ivu-modal-header
    p
      height 24px !important
      line-height 24px !important
      font-weight $font-weight-middle

  .mList
    /*width 80%*/
    margin 10px auto
    max-height 300px
    overflow auto
    .selCard
      border 1px solid $color-base !important
    .mCard:hover
      transition all 0.3s
      border-color $color-base

  .mCard
    box-sizing border-box
    font-size 0
    border 1px solid #e2e2e2
    border-radius 4px
    cursor pointer
    /*width 280px*/
    /*height 80px*/
    padding 10px 10px 10px 20px
    margin-bottom 20px
    overflow hidden
    .iblock
      display inline-block
      vertical-align middle
      .ivu-avatar
        border-radius 50%
      .showMName
        font-size $font-size-large
        color $color-font-black
      .showMPhone
        font-size $font-size-medium
        color #9b9b9b
        line-height 32px

  .lotSize
    padding 5px
    border 1px solid
    vertical-align middle
    color $color-base
    font-size $font-size-small
    border-radius 4px

  .ivu-upload
    vertical-align top

  .tr
    text-align right

  .topNav
    display inline-block
    height 70px
    line-height 70px
    font-size 14px
    vertical-align top
    float right
    li
      float right
      .myStock
        color rgb(255, 255, 255)
        display inline-block
        height 40px
        line-height 40px
        vertical-align middle
        margin-right 60px
      .myStock:hover
        color rgb(255, 255, 255)
        border-bottom 2px solid rgb(255, 255, 255)
      .U
        i
          margin-right 8px
          font-size 18px
          vertical-align middle
        span
          margin 0 20px
        .esc, .topLogin
          color #fff
          cursor pointer

  .submit
    background rgba(250, 177, 0, 0.9)
    color #fff
    width 200px
    margin 0 auto
    border none

  .loginCon
    .ivu-form-item:nth-last-child(1)
      margin-bottom 5px

  .loginBtn
    background rgba(250, 177, 0, 0.9)
    color #fff
    margin 30px auto 0 auto
    border none

  .getCodeBtn
    width 103px
    background-color rgba(250, 177, 0, 0.9)
    color #fff
    border none

  .FT
    background rgba(46, 46, 48, 1)
    height 120px
    color rgba(255, 255, 255, 1)
    h2
      font-size 60px
    .qrCard
      background rgba(46, 46, 48, 1)
      text-align center
      img
        width 100px
        height 100px

  .demo-upload-list
    display inline-block
    width 122px
    height 122px
    text-align center
    line-height 122px
    border 1px solid transparent
    border-radius 4px
    overflow hidden
    background #fff
    position relative
    box-shadow 0 1px 1px rgba(0, 0, 0, .2)
    margin-right 4px

  .demo-upload-list img
    width 100%
    height 100%

  .demo-upload-list-cover
    display none
    position absolute
    top 0
    bottom 0
    left 0
    right 0
    background rgba(0, 0, 0, .6)

  .demo-upload-list:hover .demo-upload-list-cover
    display block

  .demo-upload-list-cover i
    color #fff
    font-size 20px
    cursor pointer
    margin 0 2px

</style>
